package com.qianbao.dao.step;

import com.qianbao.domain.step.StepEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface RunStepDao {


    /**
     * 根据用户id查询出当前的数据
     * @param custom_id
     * @return
     */
    @Select("select * from sys_user_step_number where custom_id = #{custom_id}")
    public StepEntity findRunStepWithCustomId(String custom_id);


    /**
     * 保存用户步数信息 不知道能不能用，外面没有用
     * @param entity
     * @return
     */
    @Insert("INSERT INTO sys_user_step_number (custom_id,current_step,prechare_step) " +
            "VALUES (#{custom_id},#{current_step},#{prechare_step}) " +
            "ON DUPLICATE KEY UPDATE " +
            "current_step = #{current_step}, prechare_step = #{prechare_step}")
    public int saveStepInformation(StepEntity entity);


    /**
     * 插入一条步数数据
     * @param entity
     * @return
     */
    @Insert("INSERT INTO sys_user_step_number (custom_id,current_step,prechare_step) " +
            "VALUES (#{custom_id},#{current_step},#{prechare_step})")
    public int insertStepInformation(StepEntity entity);


    /**
     * 更新用户步数信息
     * @param entity
     * @return
     */
    @Update("update sys_user_step_number set current_step = #{current_step}," +
            "prechare_step = #{prechare_step} where custom_id = #{custom_id}")
    public int updateStepInformation(StepEntity entity);


    /**
     * 定时任务清空
     * @return
     */
    @Update("UPDATE sys_user_step_number SET prechare_step = 0,current_step = 0")
    public int clearStepInformation();


}
